package com.gxjc.dao.bean;

import java.util.List;

import org.hibernate.Session;

import com.gxjc.model.Power;

public class PowerDao extends BaseDao {
	public List<Power> getAll() {
		String hql = "FROM Power";
		return getSession().createQuery(hql).list();
	}

	public void save(Power power) {
		Session session = getSession();
		session.save(power);
		session.getTransaction().commit();
		session.close();
	}

	public void update(Power power) {
		Session session = getSession();
		session.update(power);
		session.getTransaction().commit();
		session.close();
	}
	
	public void delete(int id) {
		getSession().delete(getSession().get(Power.class,id));
	}
	
	public Power getPowerById(int id) {
		return (Power)getSession().get(Power.class,id);
	}
	
	public List<Power> getPowerBySql(String hql) {
		return getSession().createQuery(hql).list();
	}
}
